package yf.mall.controller;

import com.qiniu.util.Auth;
import com.yf.response.R;
import com.yf.service.QiniuService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/dmz/qiniu/token")
public class QiNiuController {

    @Value("${Qiniu.AK}")
    private String AK;
    @Value("${Qiniu.SK}")
    private String SK;

    @Resource
    private QiniuService qiniuService;

    @RequestMapping("/{bucket}")
    public R token(@PathVariable String bucket){
        Auth auth = Auth.create(this.AK, this.SK);
        String upToken = auth.uploadToken(bucket);
        return R.ok(upToken);
    }

}
